package com.xuyoupeng.springlearn.bean.common;

import com.xuyoupeng.springframework.beans.BeansException;
import com.xuyoupeng.springframework.beans.factory.config.BeanPostProcessor;
import com.xuyoupeng.springlearn.bean.UserService;

/**
 * @author xuyoupneg
 * @description TODO
 * @date 2024/3/22 15:15
 */
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if ("userService".equals(beanName)) {
            UserService userService = (UserService) bean;
            userService.setGender('0');
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }
}
